﻿using System;
using Abp.Runtime.Validation;
using pandx.Mulan.Dto;

namespace pandx.Mulan.Auditing.Dto
{
    public class ObtainAuditLogsInput:PagedAndSortedInput,IShouldNormalize
    {
        
        public DateTime StartTime { get; set; }
        
        public DateTime EndTime { get; set; }

        public string UserName { get; set; }
        
        public string ServiceName { get; set; }

        public string MethodName { get; set; }

        public string BrowserInfo { get; set; }
        
        public bool? HasException { get; set; }

        public int? MinExecutionDuration { get; set; }
        
        public int? MaxExecutionDuration { get; set; }
        
        public string ClientIpAddress { get; set; }

        public void Normalize()
        {
            if (string.IsNullOrEmpty(Sorting))
            {
                Sorting = "AuditLog.ExecutionTime DESC";
            }
            else if (Sorting.Contains("UserName", StringComparison.OrdinalIgnoreCase))
            {
                Sorting = "User." + Sorting;
            }
            else
            {
                Sorting = "AuditLog." + Sorting;
            }
        }
    }
}